package com.example.selfcontrol.controller;

import com.example.selfcontrol.config.Response;
import com.example.selfcontrol.service.LikeOptService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/like")
@Api(value = "点赞视图")
public class LikeOptController {

    @Autowired
    private LikeOptService likeOptService;

    @GetMapping("/add")
    @ApiOperation("点赞")
    public Response ClickLike(int articleId , int userId) {
        return likeOptService.ClickLike(articleId,userId) ;
    }

    @GetMapping("/islike")
    @ApiOperation("查询当前文章是否点赞")
    public boolean isLike(int userId , Long articleId) {
        return likeOptService.isLike(userId,articleId) ;
    }

    @GetMapping("/count")
    @ApiOperation("单文章点赞数量")
    public int CountLike(Long articleId) { return likeOptService.CountLike(articleId) ; }
}
